{% extends '_partials/index.twig' %}

{% block head %}
    {{ parent() }}

    {{ css.inline('resources/css/blog.scss')|raw }}
    {{ css.inline('resources/css/overview.scss')|raw }}
{% endblock %}

{% block content %}
    <header class="wrapper">
        <h1>
            {{ title }} —  stitcher.io
        </h1>

        {% include '_partials/header_links.twig' %}
    </header>

    {% if intro is defined %}
        <article>
            {{ intro|raw }}
        </article>
    {% endif %}

    <div class="wrapper">
        <nav class="overview">
            {% for post in posts %}
                <a href="/blog/{{ post.id }}">
                    {% if post.title is defined %}
                        <h1>
                            {{ post.title }}
                        </h1>
                    {% endif %}

                    <div>
                        {% if post.date is defined %}
                            <aside>
                                {% if post.author is defined %}
                                    Written by {{ post.author.name }} on
                                {% endif %}
                                {{ post.date|date("F d, Y") }}
                            </aside>
                        {% endif %}
                    </div>
                </a>
            {% endfor %}
        </nav>
    </div>

    <footer>
        <nav>
            {% if _pagination.previous.url %}
                <a href="{{ _pagination.previous.url }}" class="prev cta cta-light">
                    Previous
                </a>
            {% endif %}

            {% if _pagination.next.url %}
                <a href="{{ _pagination.next.url }}" class="next cta cta-light">
                    Next
                </a>
            {% endif %}
        </nav>

        {% include '_partials/links.twig' %}
    </footer>
{% endblock %}
